package com.dmap.officialwebsite.controller.background;

import com.dmap.base.vo.BaseVo;
import com.dmap.officialwebsite.po.ArticleType;
import com.dmap.officialwebsite.service.ArticleTypeService;
import com.dmap.officialwebsite.vo.ArticleTypeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * \* User: helei
 * \* Date: 03/09/18
 * \* Description:
 * \
 */
@Api(value = "文章类型管理", description = "background/文章类型管理")
@Controller
@RequestMapping(value = "/background/dmap-officialwebsite-server/v1/user/articleType/")
public class ArticleTypeController {

    @Resource
    private ArticleTypeService articleTypeService;

    @ResponseBody
    @ApiOperation(value = "查询文章类型", notes = "文章类型")
    @RequestMapping(value = "select/selectAll", method = RequestMethod.GET)
    public BaseVo select() {
        BaseVo baseVo = new BaseVo();
        List<ArticleType> articleTypeList = articleTypeService.selectAll();
        List<ArticleTypeVo> articleTypeVoList = new ArrayList<>();
        articleTypeList.forEach(articleType -> {
            articleTypeVoList.add(new ArticleTypeVo(articleType));
        });
        baseVo.setData(articleTypeVoList);
        return baseVo;
    }

}
